//
//  MYShopDetailsDistributionView.m
//  MuYing
//
//  Created by tbb on 2019/7/30.
//  Copyright © 2019 TBB. All rights reserved.
//

#import "MYShopDetailsDistributionView.h"
#define kTABLEVIEW_H 256
@implementation MYShopDetailsDistributionView
+ (void)showShopDetailsExplainView {
    MYShopDetailsDistributionView *screenView = [[MYShopDetailsDistributionView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    screenView.backgroundColor = HexColorA(0x000000, 0.2);//HexColor(0xF3F5F9);
    [screenView showSelctTableView];
}

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.selectTableView registerNib:[UINib nibWithNibName:@"MYShopDetailsDistributionCell" bundle:nil] forCellReuseIdentifier:@"MYShopDetailsDistributionCell"];
        self.selectTableView.backgroundColor = UIColor.whiteColor;
        self.selectTableView.frame = CGRectMake(0, kYQPScreenHeight + kTABLEVIEW_H, kYQPScreenWidth, kTABLEVIEW_H);
        [self addSubview:self.selectTableView];
        [UIView roundedSetView:self.selectTableView cornerRadius:12 Type:(kRoundedSetViewTypeTRL)];
    }
    return self;
}

-(void)showSelctTableView {
    //1. 获取当前应用的主窗口
    
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    [keyWindow addSubview:self];
    // 浮现动画
    [UIView animateWithDuration:0.3 animations:^{
        self.selectTableView.top = kYQPScreenHeight - kTABLEVIEW_H-kHeight_Botton_SafeArea;
    }];
    
}

-(void)cancelSelctTableView {
    
    // 关闭动画
    [UIView animateWithDuration:0.5 animations:^{
        self.selectTableView.top = kYQPScreenHeight + kTABLEVIEW_H;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
}

#pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    MYShopDetailsDistributionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MYShopDetailsDistributionCell"];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 68;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 53;
    }else{
        return 38;
    }
    
}
#pragma mark - UITableViewDelegate, UITableViewDataSource end
@end
